import java.util.*;

class Solution1 {

    public static int[] twoSum(int[] nums, int target) {
        int[] result = new int[2];

        HashMap<Integer,Integer> map = new HashMap<>();
        for (int i = 0; i < nums.length; i++) {
            int num = nums[i];
            if (map.containsKey(num)){
                result[0] = map.get(num);
                result[1] = i;
                return result;
            }
            map.put(target - num, i);
        }
        return result;
    }
}
